function AjaxObject() {
    this.readyState = 0;
    this.responseText = "";
    this._createAjaxObject()
}
AjaxObject.prototype = {GET:"GET", POST:"POST", open:function (b, a) {
    if (!this.ajax) {
        return
    }
    a += a.indexOf("?") == -1 ? "?" : "&";
    a += "csrf_token=" + (window.csrf_token || "");
    this.ajax.open(b, a, true);
    if (b == this.POST) {
        this.ajax.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
        this.ajax.setRequestHeader("Connection", "close")
    }
}, send:function (a) {
    if (!this.ajax) {
        return
    }
    try {
        this.ajax.send(a)
    } catch (b) {
    }
}, abort:function () {
    if (!this.ajax) {
        return
    }
    this.ajax.abort()
}, onreadystatechange:function () {
    return true
}, _onreadystatechange:function () {
    this.readyState = this.ajax.readyState;
    if (this.readyState == 4) {
        this.contentType = this.ajax.getResponseHeader("Content-Type");
        this.responseText = this.ajax.responseText;
        if (typeof(this.onreadycontent) == "function" && this.ajax.status == 200) {
            return this.onreadycontent()
        } else {
            if (typeof(this.onerrorstate) == "function" && this.ajax.status != 200) {
                return this.onerrorstate()
            }
        }
    }
    try {
        if (typeof(this.onreadystatechange) == "function" && this.ajax.status == 200) {
            return this.onreadystatechange()
        }
    } catch (a) {
    }
    return false
}, _createAjaxObject:function () {
    this.ajax = this._getAjaxObject();
    if (!this.ajax) {
        return null
    }
    var a = this;
    this.ajax.onreadystatechange = function () {
        a._onreadystatechange()
    };
    return true
}, _getAjaxObject:function () {
    try {
        return new XMLHttpRequest()
    } catch (c) {
        var a = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"];
        for (var b = 0; b < a.length; b++) {
            try {
                return new ActiveXObject(a[b])
            } catch (c) {
            }
        }
        return false
    }
}};
function AJAXRequest(method, param, readycontent_func, errorstate_func, evalfail_func) {
    if (!readycontent_func || typeof(readycontent_func) != "function") {
        return
    }
    var url = "/registered/main.pl";
    var ajax = new AjaxObject();
    if (errorstate_func && typeof(errorstate_func) == "function") {
        ajax.onerrorstate = errorstate_func
    }
    ajax.onreadycontent = function () {
        if (this.contentType.search(/^text\/xml/) != -1) {
            readycontent_func(this.ajax.responseXML)
        } else {
            if (this.contentType.search(/^text\/plain/) != -1) {
                readycontent_func(this.responseText)
            } else {
                if (this.contentType.search(/^application\/x-javascript/) != -1) {
                    var res;
                    try {
                        res = eval("(" + this.responseText + ")")
                    } catch (e) {
                        if (evalfail_func && typeof(evalfail_func) == "function") {
                            evalfail_func()
                        }
                        return
                    }
                    readycontent_func(res)
                } else {
                    if (errorstate_func && typeof(errorstate_func) == "function") {
                        errorstate_func()
                    }
                    return
                }
            }
        }
    };
    var param_str = "";
    if (typeof(param) == "string") {
        param_str = param.replace(/^\?/, "")
    } else {
        if (typeof(param) == "object") {
            for (var name in param) {
                if (!param.hasOwnProperty(name)) {
                    continue
                }
                if (name != "") {
                    param_str += "&" + escape(name).replace(/\+/g, "%2B") + "=" + escape(param[name]).replace(/\+/g, "%2B")
                }
            }
        }
    }
    if (method == "GET") {
        ajax.open("GET", url + "?" + param_str);
        ajax.send()
    }
    if (method == "POST") {
        ajax.open("POST", url);
        ajax.send(param_str)
    }
}
;
